package com.bj58.ecdata.dashboard.controllers;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.bj58.ecdata.dashboard.cache.ServiceBeanFactory;
import com.bj58.ecdata.dashboard.constant.IncomeCityConst;
import com.bj58.ecdata.dashboard.constant.InfoConst;
import com.bj58.ecdata.dashboard.constant.ResumeConst;
import com.bj58.ecdata.dashboard.databll.ResumeBLL;
import com.bj58.ecdata.dashboard.dbentity.ResumeEntBasic;
import com.bj58.ecdata.dashboard.dbentity.ResumeIndBasic;
import com.bj58.ecdata.dashboard.dbentity.ResumeQuantity;
import com.bj58.ecdata.dashboard.dbentity.ResumeTalentInflow;
import com.bj58.ecdata.dashboard.service.AbstractBaseService;
import com.bj58.ecdata.dashboard.utils.DateUtil;
import com.bj58.wf.mvc.ActionResult;
import com.bj58.wf.mvc.MvcController;
import com.bj58.wf.mvc.annotation.GET;
import com.bj58.wf.mvc.annotation.POST;
import com.bj58.wf.mvc.annotation.Path;

/**
 * 简历看板Controller
 * 
 * @author zhaoxiang 2015-08-19
 */
@Path("/resume")
public class ResumeController extends MvcController {
	private final AbstractBaseService<ResumeTalentInflow> resumeTalentInflowService = ServiceBeanFactory.get(ResumeTalentInflow.class, null);
	private AbstractBaseService<ResumeIndBasic> ResumeIndService = ServiceBeanFactory.get(ResumeIndBasic.class, null);
	
	private AbstractBaseService<ResumeEntBasic> ResumeEntService = ServiceBeanFactory.get(ResumeEntBasic.class, null);
	
	private AbstractBaseService<ResumeQuantity> ResumeQuantityService = ServiceBeanFactory.get(ResumeQuantity.class, null);
//	private AbstractBaseService<ResumeEntWord> ResumeEntWordService = ServiceBeanFactory.get(ResumeEntWord.class, null);


	/**
	 * 简历基础数据
	 *  求职者整体数据+企业整体数据+简历整体数据+职位整体数据
	 * @param
	 * @return
	 * @author guoxue 2015-08-17
	 */
	@Path({ "/totalData" })
	// @Check("dashboard/resume/totalData")
	@GET
	@POST
	public ActionResult dashboard() {
		try {
			
			//表格--求职者整体数据
			String maxDate = ResumeIndService.getMaxDate();			
			List<List<Object>> list = ResumeBLL.getGeneral(maxDate);
			
			//表格--企业整体数据			
			String maxDate2 = ResumeEntService.getMaxDate();					
			List<List<Object>> list2 = ResumeBLL.getGeneral2(maxDate2);
			
//			//简历数量供应		
//			String maxDate3 = ResumeQuantityService.getMaxDate();
//			
//			//企业搜索热词
//			String maxDate4 = ResumeEntWordService.getMaxDate();
			
			Map<String, Object> context = beat.getModel().getModel();
			
			context.put("tableData", list);
			context.put("tableData2", list2);
			
			context.put("stat_date", DateUtil.strToStr(maxDate, "yyyy.MM.dd"));
			context.put("stat_date2", DateUtil.strToStr(maxDate2, "yyyy.MM.dd"));
		
			//城市和类别
			context.put("CityList",ResumeConst.CityList);		
			context.put("CateList",ResumeConst.CateList);
			
//			context.put("maxDate", maxDate3);
//			context.put("maxDate2", maxDate4);

		} catch (Exception e) {
			return ActionResult.view("null");
		}
		return ActionResult.view("resume/totaldata");

	}

	/**
	 * 简历流动数据
	 * 简历流动数据=简历投递→阅读→下载转化+下载专题
	 * @author zhaoxiang 2015-08-19
	 */
	@Path({ "/resumeFlow" })
	// @Check("dashboard/resume/resumeFlow")
	@GET
	@POST
	public ActionResult readDownLoad() {
		try {
			// String maxDate = infoService.getMaxDate();
			String maxDate = "2015-07-21";
			Map<String, Object> context = beat.getModel().getModel();
			context.put("zhixiaoCityList", IncomeCityConst.ZX_CityList); // 直销城市
			context.put("cateTwoList", InfoConst.resumeCateList);
			context.put("resumeCrowdMap", ResumeConst.resumeCrowdMap);
			context.put("maxDate", maxDate);
		} catch (Exception e) {
			return ActionResult.view("null");
		}
		return ActionResult.view("resume/total");

	}

	/**
	 * 简历供应
	 * 简历供应=人才流动+数量供应+质量匹配
	 * @author 
	 */
	
	@Path({ "/resumeProvision" })
	// @Check("dashboard/resume/resumeProvision")
	@GET
	@POST
	public ActionResult dashboardforresume() {
		try {
			// 整体流量
			String maxDate = resumeTalentInflowService.getMaxDate();
			// String maxDate = "2015-07-21";
			Map<String, Object> context = beat.getModel().getModel();
			context.put("zhixiaoCityList1",JSONArray.parseArray("['北京','上海', '天津', '广州', '深圳', '成都', '重庆', '石家庄', '济南', '青岛', '南京', '杭州', '苏州', '无锡', '合肥', '武汉', '郑州', '长沙', '福州', '厦门', '南宁', '哈尔滨', '长春', '太原', '大连', '沈阳', '东莞']")); // 直销城市
			context.put("cateTwoList1",JSON.parseArray("['销售', '普工/技工', '餐饮', '人事/行政/后勤', '司机/交通服务', '超市/百货/零售', '物流/仓储', '教育培训', '客服', '财务/审计/统计', '建筑', '家政保洁/安保', '淘宝职位', '美容/美发', '医院/医疗/护理', '酒店/旅游', '娱乐/休闲', '传单派发', '计算机/互联网/通信', '美术/设计/创意', '汽车制造/服务', '促销/导购', '贸易/采购', '服务员', '生产管理/研发', '金融/银行/证券/投资', '市场/公关/媒介']"));
			context.put("time_input_TalentinflowPro", maxDate);
			
//			//简历数量供应		
			String maxDate3 = ResumeQuantityService.getMaxDate();
			context.put("maxDate", maxDate3);
			
			//城市和类别
			context.put("CityList",ResumeConst.CityList);		
			context.put("CateList",ResumeConst.CateList);
			
			//质量匹配
			context.put("zhixiaoCityList", IncomeCityConst.ZX_CityList); // 直销城市
			context.put("cateTwoList", InfoConst.resumeCateList);
			context.put("resumeCrowdMap", ResumeConst.resumeCrowdMap);
			
		} catch (Exception e) {
			return ActionResult.view("null");
		}
		return ActionResult.view("resume/talentinflow");
	}
	

	/**
	 * 简历销售
	 * 
	 * @author guoxue
	 */
	@Path({ "/resumeIncome" })
	// @Check("dashboard/resume/resumeIncome")
	@GET
	@POST
	public ActionResult resumeIncome() {
		try {
					
			Map<String, Object> context = beat.getModel().getModel();
				
			//城市和类别
			context.put("CityList",ResumeConst.CityList);		
			context.put("CateList",ResumeConst.CateList);
			
		} catch (Exception e) {
			return ActionResult.view("null");
		}
		return ActionResult.view("resume/resumeincome");
	}
	
}
